<?php

require_once('classes/Mapping/AbstractMappingConfig.class.php');
require_once('classes/Mapping/BasicProcessedMappingConfig.class.php');

class InnerWorkingPublicResourceMapping extends AbstractMappingConfig implements RequestMapping{

    protected $prefix = '/~';
    protected $file;

    public function InnerWorkingPublicResourceMapping(){
    }

    protected function getFileName($uri = null){
        if ($this->file !== null){
            return $this->file;
        }
        return $this->file = dirname(__FILE__).'/../../../publicResources/'.substr($uri,strlen($this->prefix)).'.php';
    }

    public function checkMapping($uri){
        if (!$this->configObj->conditionsMet()){
            return false;
        }
        return substr($uri,0,strlen($this->prefix)) == $this->prefix && file_exists($this->getFileName($uri));
    }

    public function run(){
        $this->configObj->run();
        $this->includeFile($this->getFileName());
    }

    public static function getXsdPart(){
        return '';
    }

    public static function interpretXmlConfig(/*XMLNodeList?*/ $item, /*RequestInterpreter*/ $interpreter){
        $name = $item->localName;
        $interpreter->addMapping(new $name());
    }

}

?>